package cn.ecsd.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import cn.ecsd.common.CommonDao;
import cn.ecsd.entity.SysEmployee;
import cn.ecsd.service.EmployeeService;

//@Service("employeeService")
public class EmployeeServiceImpl implements EmployeeService {
	//@Autowired
	//@Qualifier(value="commonDao")
	private CommonDao commonDao;

	public CommonDao getCommonDao() {
		return commonDao;
	}

	public void setCommonDao(CommonDao commonDao) {
		this.commonDao = commonDao;
	}

	/**
	 * 员工登陆
	 */
	@Override
	public SysEmployee empLogin(SysEmployee employee) {
		String sql = "from SysEmployee e where e.sn='" + (employee.getSn() + "'");
		List list = commonDao.search(sql);
		if (list .size()!=0)
			return (SysEmployee) list.get(0);
		return null;
	}

	@Override
	public SysEmployee getManagerByDeparId(SysEmployee e) {
		String sql="from SysEmployee e where e.sysPosition.id=2 and e.sysDepartment.id="+e.getSysDepartment().getId();
		if(commonDao.search(sql).size()!=0){
			return (SysEmployee) commonDao.search(sql).get(0);
		}
		return null;
	}

}
